/*
 * CashRegister.h
 *
 *  Created on: May 30, 2011
 *      Author: peckb1
 *
 *  The Cash Register:
 *      Allows a clerk to run the till of this register, and help customers
 *      checkout with their goods.
 */

#ifndef CASHREGISTER_H_
#define CASHREGISTER_H_

#include "system.h"
#include "synch.h"
#include "list.h"
#include "bool.h"
#include "item.h"
#include "locks.h"

class Customer;
class Clerk;

class CashRegister {
    private:
        double tillBalance;    // current balance in the till

        double currentCustomerBalance; // the current balance the customer being
                                       // helped has accrued
        int currentClerkId; // the id of the clerk using me

        int currentItemCount; // the number of items for the customer being helped on me

        int myId; // My current Id

        int currentCustomerId; // Customer that is being helped by currentClerkId on me

        Locks *theLocks;
        /*
         * Method to interact with a Clerk
         */
        void InteractWithClerk();

        /*
         * Method to interact with a manager
         */
        void InteractWithManager();
    public:
        void IncreaseSales(double newVal)
        {
        	(theLocks->registerSales[myId]) += newVal;
        }
        void SetTotalSales(double newVal){
        	theLocks->registerSales[myId] = newVal;
        }
        double GetTotalSales()
        {
        	return theLocks->registerSales[myId];
        }
        CashRegister(int registerId, int clerkId, Locks* allTheLocks);  // allocate the CashRegister
        ~CashRegister(); // de-allocate the CashRegister

        // Entry Method for the Cash Register Thread
        void DoWork();
};

#endif /* CASHREGISTER_H_ */
